package c.x.jy.dao.dao;

import c.x.jy.dao.entity.CmsArticleEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * 
 * 
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-22 16:38:13
 */
@Mapper
public interface CmsArticleDao extends BaseMapper<CmsArticleEntity> {
    @Update(" UPDATE `t_cms_article` SET `hits`=`hits`+1 WHERE (`article_data_id`=${id}  ) LIMIT 1 ")
    int updateHits(Long id);

    @Select("select * from t_cms_article ${ew.customSqlSegment}")
    IPage<CmsArticleEntity> selectPages(IPage<CmsArticleEntity> page, @Param(Constants.WRAPPER) QueryWrapper<CmsArticleEntity> query);

    @Select("select * from t_cms_article where category_ids like '%\"${ids}\"%' order by create_date desc limit 6")
    List<CmsArticleEntity> selectListforHome(String ids);
}

